package main;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;
import java.util.Properties;

import org.mitre.jawb.io.SgmlDocument;

import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.ling.CoreAnnotations.PartOfSpeechAnnotation;
import edu.stanford.nlp.ling.CoreAnnotations.SentencesAnnotation;
import edu.stanford.nlp.ling.CoreAnnotations.TextAnnotation;
import edu.stanford.nlp.ling.CoreAnnotations.TokensAnnotation;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.util.CoreMap;
import edu.washington.cs.knowitall.nlp.ChunkedSentence;
import edu.washington.cs.knowitall.nlp.OpenNlpChunkedSentenceParser;
import edu.washington.cs.knowitall.nlp.OpenNlpSentenceChunker;

public class ChunkerTester {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		
		 // creates a StanfordCoreNLP object, with POS tagging, lemmatization, NER, parsing, and coreference resolution 
	    Properties props = new Properties();
//	    props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
	    
	    props.put("annotators", "tokenize, ssplit, pos");
	    	    
	    StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
	    
	    SgmlDocument sgmlDocument = new SgmlDocument(new FileReader(new File("/home/pjbarrio/Dataset/SGML-ACE/AT/0/trainingDirectory/9801.35.sgm")));
	    
	    // read some text in the text variable
	    String text = "The Senate yesterday confirmed three federal judges in its first official action " +
	    		"of the year, slightly reducing the backlog of nominations that has drawn " +
	    		"criticism from both President Clinton and Chief Justice William H. Rehnquist. " +
	    		"But the dispute over the Senate's pace in dealing with nominations continued, " +
	    		"with Republicans defending the record while Democrats charged the GOP with " +
	    		"politicizing the process. " +
	    		"By a vote of 67 to 30, the Senate confirmed Ann L. Aiken for a U.S. District " +
	    		"Court vacancy in Oregon. Her nomination had been held up for months by Sen. Mike " +
	    		"Enzi (R-Wyo.), who accused her of leniency in sentencing a child molester when " +
	    		"she was a state court judge. " +
	    		"Senate Judiciary Committee Chairman Orrin G. Hatch (R-Utah) said that while " +
	    		"Aiken would not have been his choice, she \"demonstrated to me that she " +
	    		"understands the proper role of a federal judge in our constitutional system.\" " +
	    		"By voice vote, the Senate also confirmed Richard W. Story for the federal " +
	    		"district court in Georgia and Barry G. Silverman of Arizona for the Ninth U.S. " +
	    		"Circuit Court of Appeals, which has jurisdiction over California and other " +
	    		"western states. " +
	    		"Yesterday's action reduces the list of judicial vacancies to 85, or about 10 " +
	    		"percent of the federal judiciary. The Senate confirmed 17 judges in 1996 and 36 " +
	    		"judges last year, drawing accusations of foot-dragging from Democrats. Hatch and " +
	    		"others said Clinton was mostly to blame because he was slow to make nominations. " +
	    		"More than 50 nominations are pending before the Senate, including 12 made on " +
	    		"Tuesday. " +
	    		"The long-simmering dispute over the Senate's performance on nominations came to " +
	    		"a head when Rehnquist warned in a year-end report that the judicial vacancies " +
	    		"were threatening the nation's \"quality of justice\" and the White House pounced " +
	    		"on his words to mount a campaign for speedier action. " +
	    		"\"; // Add your text here!";
	    
	    // create an empty Annotation just with the given text
	    Annotation document = new Annotation(text);
	    
	    // run all Annotators on this text
	    pipeline.annotate(document);
	    
	    // these are all the sentences in this document
	    // a CoreMap is essentially a Map that uses class objects as keys and has values with custom types
	    List<CoreMap> sentences = document.get(SentencesAnnotation.class);
	    
	    for(CoreMap sentence: sentences) {
	      // traversing the words in the current sentence
	      // a CoreLabel is a CoreMap with additional token-specific methods
	      
	    	System.out.println("\nSentence");
	    	
	    	for (CoreLabel token: sentence.get(TokensAnnotation.class)) {
	        // this is the text of the token
	    	
	    		
		    	      	  
		        String word = token.get(TextAnnotation.class);
		        
		        System.out.print(token.beginPosition() + " - " + token.index() + " - " + word + " ");
		        // this is the POS tag of the token
		        String pos = token.get(PartOfSpeechAnnotation.class);
		        
		        System.out.println(pos + " ");
		        // this is the NER label of the token
//		        String ne = token.get(NamedEntityTagAnnotation.class);       
//		      
//		        System.out.println(ne + " ");
	        
	    }

	      // this is the parse tree of the current sentence
//	      Tree tree = sentence.get(TreeAnnotation.class);

	      // this is the Stanford dependency graph of the current sentence
//	      SemanticGraph dependencies = sentence.get(CollapsedCCProcessedDependenciesAnnotation.class);
	    }
		
	}

}
